package com.springapp.mvc.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by yjhan on 2014. 7. 4..
 */

@Controller
public class IndexController {

    @RequestMapping( value = {"/","/welcome**"}, method = RequestMethod.GET )
    public ModelAndView welcomePage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title","Spring Security Hello~");
        model.addObject("message","This is welcome page!");
        model.setViewName("hello");

        return model;
    }

    @RequestMapping( value = "/admin**", method = RequestMethod.GET)
    public ModelAndView adminPage() {

        ModelAndView model = new ModelAndView();
        model.addObject("title", "Spring Security admin page");
        model.addObject("message", "This is protected page");
        model.setViewName("admin");

        return model;
    }

}
